<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="./extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="./extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./extjs/ext-all.js"></script>
<script>
var LoginForm;
LoginWindow=Ext.extend(
	Ext.Window,
	{   
		title : '登陆系统', 
		modal : true,          
		width : 265,              
		height : 170,           
		defaults : {border : false },   
		buttonAlign : 'center',      
		createFormPanel :function() 
			{   
				return LoginForm=new Ext.form.FormPanel( 
					{   
						bodyStyle : 'padding-top:6px',   
						defaultType : 'textfield',   
						labelAlign : 'right',   
						labelWidth : 55,   
						labelPad : 0,   
						frame : true,   
						defaults : { allowBlank : false,  width : 158},
						items : [
									{   
										cls : 'user',
										id: 'username',
										name : 'username',   
										fieldLabel : '帐号',   
										blankText : '帐号不能为空'  
									}, 
									{   
										cls : 'key',
										id : 'password',   
										name : 'password',   
										fieldLabel : '密码',   
										blankText : '密码不能为空',   
										inputType : 'password'  
									}
								]   
					}
					);   
			},                      
		login:function() {
			
			var userName=Ext.getCmp("username").getValue();
        	var pwd=Ext.getCmp("password").getValue();
  			if (userName=="" || pwd=="")
			{
				alert("用户名或密码不能为空")
				return;
			}
			this.fp.form.submit(
			{   
				waitMsg : '正在登录......',   
				url : 'http://localhost:8080/ema/SrvLogin',     
				failure:function(form, action) 
				{ 
 					var flag=action.result.msg;
					if(flag=="invalid")
					{
						alert('用户名或密码不正确,请重新输入');
    					window.location.href = 'index.html'; 
					}
					else
					{
						alert('系统错误,无法完成登陆校验');
					}  
				},//end function failure 
				success:function(form, action)
				{//登陆成功后显示页面
					window.location.href = 'index.html';   
				}//end function success
			}
			); //end function submit  
		},//end function login    
		initComponent : function()
		{   
			LoginWindow.superclass.initComponent.call(this);         
			this.fp=this.createFormPanel();   
			this.add(this.fp);   
			this.addButton('登陆',this.login,this);   
			this.addButton('重置', function(){this.fp.form.reset();},this);   
		}       
	});//end function LoginWindow
  
Ext.onReady(function()   
{	
	Ext.QuickTips.init();
	var win=new LoginWindow();   
	win.show();   
}   
); 


</script>
</head>

<body>
<Table></Table>
qweqw<a href="www.sohu.com" title="WAHAHAHAH">eqweqw</a> 
</body>
</html>
